package com.isunland.managesystem.adapter;

import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.RequisitionSimpleOriginal;
import com.isunland.managesystem.ui.CheckDetailFragment;
import com.isunland.managesystem.utils.MyStringUtil;
import com.isunland.managesystem.utils.MyUtils;
import java.util.ArrayList;

/**
 * 对象功能:
 * 开发公司: 北京信普达系统工程有限公司
 * 开发人员: wangyanan
 * 创建时间: 2017/4/5 15:01
 */

public class RequisitionListAdapter extends BaseButterKnifeAdapter<RequisitionSimpleOriginal> {

  @SuppressWarnings("unused") public RequisitionListAdapter(BaseVolleyActivity context,
      ArrayList<RequisitionSimpleOriginal> objects) {
    super(context, objects);
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_attendance_query;
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  @Override
  protected void initView(RequisitionSimpleOriginal item, BaseViewHolder baseHolder, int position) {
    ViewHolder vh = (ViewHolder) baseHolder;
    vh.tvApplyTime.setVisibility(View.GONE);
    MyUtils.switchShadowStutus(context, vh.mContentStatusTv, item.getDataStatus());
    vh.mContentTwoTv.setText(item.getTitle());//事由
    //不用单据类型显示不同时间
    String mattendType = item.getAttendType();
    if (CheckDetailFragment.VALUE_UNPUNCH.equalsIgnoreCase(mattendType)) {
      //未打卡
      if (!TextUtils.isEmpty(item.getActSTime())) {
        vh.mContentThreeTv.setText(
            MyStringUtil.connect(context.getString(R.string.actualUnpunchTime),
                item.getActSTime()));//"打卡时间："+"2016-01-16 9:00"
      } else {
        vh.mContentThreeTv.setText("");
      }
    } else if (CheckDetailFragment.VALUE_OFF.equalsIgnoreCase(mattendType)) {
      //调休
      if (!TextUtils.isEmpty(item.getHolyKindName()) && !TextUtils.isEmpty(item.getHolyDays())) {
        vh.mContentThreeTv.setText(
            item.getHolyKindName() + "：" + item.getHolyDays() + "天");//"带薪假"+"："+"2天"
      } else {
        vh.mContentThreeTv.setText("");
      }
    } else {
      if (!TextUtils.isEmpty(item.getActSTime()) || !TextUtils.isEmpty(item.getActETime())) {
        vh.mContentThreeTv.setText(item.getActSTime() + "  至  " + item.getActETime());//开始时间至结束时间
      } else {
        vh.mContentThreeTv.setText("");
      }
    }
    vh.mTypeTv.setText(item.getAttendTypeName());
    vh.mPersonNameTv.setText(
        MyStringUtil.connect(MyStringUtil.SEPEREATE, item.getRegStaffName(), MyStringUtil.SEPEREATE,
            item.getRegDate()));
  }

  @Override public boolean isEmpty() {
    return false;
  }

  protected class ViewHolder extends BaseViewHolder {
    //@BindView(R.id.tv_contentOne_simpleList) TextView tvContentOneSimpleList;
    //@BindView(R.id.ll_holderOne_simpleList) LinearLayout llHolderOneSimpleList;
    //@BindView(R.id.tv_TitleTwo_simpleList) TextView tvTitleTwoSimpleList;
    //@BindView(R.id.ll_holderTwo_simpleList) LinearLayout llHolderTwoSimpleList;
    //@BindView(R.id.tv_contentFour_simpleList) TextView tvContentFourSimpleList;
    //@BindView(R.id.tv_contentFive_simpleList) TextView tvContentFiveSimpleList;
    //@BindView(R.id.tv_contentSix_simpleList) TextView tvContentSixSimpleList;
    //@BindView(R.id.tv_contentSeven_simpleList) TextView tvContentSevenSimpleList;
    //@BindView(R.id.tv_contentEight_simpleList) TextView tvContentEightSimpleList;
    //@BindView(R.id.ll_holderThree_simpleList) LinearLayout llHolderThreeSimpleList;
    @BindView(R.id.ll_planStatus) TextView mContentStatusTv;
    @BindView(R.id.tv_contentTwo_simpleList) TextView mContentTwoTv;
    @BindView(R.id.tv_contentThree_simpleList) TextView mContentThreeTv;
    @BindView(R.id.tv_type) TextView mTypeTv;
    @BindView(R.id.tv_person_name) TextView mPersonNameTv;
    @BindView(R.id.tv_applyTime) TextView tvApplyTime;

    //@BindView(R.id.tv_person_data) TextView mPersonDataTv;
    ViewHolder(View view) {
      super(view);
    }
  }
}
